using FluentNHibernate.Testing;
using NHibernate;
using NUnit.Framework;
using Sample.Domain;
using Sample.Persistence;

namespace SampleTests
{
    [TestFixture]
    public class When_verifying_mappings
    {
        #region Setup/Teardown

        [SetUp]
        public void ResetDatabase()
        {
            NHibernateHelper.GenerateSchema(false);
        }

        #endregion

        [Test]
        public void Can_validate_a_peer_review()
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                new PersistenceSpecification<PeerReview>(session)
                    .CheckProperty(x => x.Description, "Bumble Bee")
                    .CheckReference(x => x.ConductedFor, ObjectMother.ValidPerson())
                    .VerifyTheMappings();
            }
        }

        [Test]
        public void Can_validate_a_person()
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                new PersistenceSpecification<Person>(session)
                    .CheckProperty(x => x.Email, "lyra@mail.com")
                    .CheckProperty(x => x.FirstName, "Lyra")
                    .CheckProperty(x => x.LastName, "Thomas")
                    .CheckProperty(x => x.Location, ObjectMother.Location)
                    .VerifyTheMappings();
            }
        }
    }
}